package tools

import (
	"math/rand"
	"time"
)

func RandomString(strLen int) string {
	return RandomStringIn("0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", strLen)
}

func RandomStringIn(alphabet string, strLen int) string {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	var bytes = []rune(alphabet)
	var strs = make([]rune, strLen)
	for strLen > 0 {
		strs[strLen-1] = bytes[r.Intn(len(bytes))]
		strLen -= 1
	}
	return string(strs)
}
